<?php include "include/function_library.php"; ?>
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>

<?php include "html/header.html"; ?>

</head>
<body class="tcuk home">

	<div id="wp">
	
		<?php  include "html/menu.html"; ?>
		
		<!-- CONTENT STARTS-->
		<div id="ct">	
			
			<?php 
				if(get("edited") == "1") echo "<div class='alert success'>Tour Edited Successfully!</div>";
				if(get("purchased") == "1") echo "<div class='alert success'>Tour Ticket Purchased Successfully!</div>";
			
				$id = get("id");
				$query = "SELECT * from tour_with_organization WHERE id=$id";
				$result = sql_query($query);
				$tuple = mysql_fetch_assoc($result);
				
				$query_tour_cost = "select * from tour_cost where tour_id='$id'";
				$result_tour_cost = sql_query($query_tour_cost);
				$tuple_tour_cost = mysql_fetch_assoc($result_tour_cost);
				?>
				<table style="width:80%;height:100%;">
					<tr>
						<td><img alt="" src="resource/tour1foto.jpg" width="500px"></td>			
						<td>
							<h2><?php echo $tuple["name"]; ?></h2><br />
							<ul>
								<li><b>Location :</b> <?php echo $tuple["location"]; ?></li>
								<li><b>Date :</b> <?php echo $tuple["start_date"]; ?> - <?php echo $tuple["end_date"]; ?></li>
								<li><b>Company :</b> <a href="company_detail.php?id=<?php echo $tuple["oc_id"]; ?>"><?php echo $tuple["oc_name"]; ?></a></li>
								<li><b>Total Price :</b> <?php echo $tuple_tour_cost["total_price"]; ?></li>
								<li><b>Hotels :</b> 
									<ul>
									<?php 
										$query = "SELECT h.id AS h_id, name from hotel h, hotel_of_tour ht where h.id=ht.hotel_id and ht.tour_id = '$id'";
										$result = sql_query($query);
										
										while($tuple2 = mysql_fetch_assoc($result)) {
											?> <li><a href="hotel_detail.php?id=<?php echo $tuple2["h_id"]; ?>"> <?php echo $tuple2["name"] ?> </a></li> <?php 
										}
									?>
									</ul>
								</li>
							</ul>
						</td>
					</tr>
					<tr>
						<td colspan="2">
							<h3>Details</h3><br/>
							<p><?php echo $tuple["description"]; ?></p>
						</td>
					</tr>
					
					<tr>
						<td colspan="3" style="text-align:right">
							<?php
							if(session("is_customer") == "0") {
								?>
								<a href="edit_tour.php?id=<?php echo $tuple["id"]; ?>"><button>Edit</button></a>
								<a href="delete_tour.php?id=<?php echo $tuple["id"]; ?>"><button>Delete</button></a>
								<?php
							} else {
								?>
								<a href="purchase_tour.php?id=<?php echo $tuple["id"]; ?>"><button>Purchase</button></a>
								<?php
							}
							?>
						</td>
					</tr>
					
				</table>
				
							
		
		</div> 	
		<!-- CONTENT ENDS-->		
		
		<?php include "html/footer.html"; ?>
		
	</div>
	
</body>
</html>